﻿<UserControl x:Class="FIFP.DashBoard.Views.OverlapManagement_New"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"    
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    xmlns:local="clr-namespace:FIFP.DashBoard.Views"
    xmlns:converter="clr-namespace:FIFP.DashBoard.Converters"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    DataContext="{Binding OverlapVM_New,Source={StaticResource ServiceLocator}}"
    mc:Ignorable="d"             
    d:DesignHeight="1028" d:DesignWidth="1920">

    <UserControl.Resources>
        <converter:TrueToFalseConverter x:Key="TrueFalseConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Margin="0,5,0,0">


        <Grid Margin="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.5*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="0.5*"/>
            </Grid.RowDefinitions>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.15*"/>
                    <ColumnDefinition Width="0.31*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="0.38*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid x:Name="overlapPanel" Grid.Column="0" Margin="0,0,10,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Location of overlap" Grid.Row="0" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,5"/>

                    <sdk:DataGrid x:Name="overlapGroupGrid" Grid.Row="1" ItemsSource="{Binding OverlapLocations}" AutoGenerateColumns="False" IsReadOnly="True"
                             Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <i:InvokeCommandAction Command="{Binding OverlapLocationSelectionChanged}" 
        							CommandParameter="{Binding ElementName=overlapGroupGrid}" />
                            </i:EventTrigger>
                            <i:EventTrigger EventName="LoadingRow">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=OverlapVM_New.OverlapLocationGridLoadingRowCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />                               
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Header="Type" Width="*" Binding="{Binding OverlapType}" MinWidth="90"  />
                            <sdk:DataGridTextColumn Header="Unit Name" Width="*" Binding="{Binding OverlapLocation}" MinWidth="90"  />
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </Grid>

                <Grid x:Name="overlapPlansPanel" Grid.Column="1" Margin="0,0,0,0">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Overlapped Activities" Grid.Row="0"  Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,5"/>

                    <sdk:DataGrid x:Name="overlapPlansGrid" Grid.Row="1" ItemsSource="{Binding OverlappedActivities}" AutoGenerateColumns="False" IsReadOnly="True"
                           Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch">

                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <RadioButton Name="chkPlans" Tag="{Binding Overlap_Id}" Visibility="{Binding RadioButtonVisibility}" GroupName="Overlap"
                                                   Command="{Binding Source={StaticResource ServiceLocator}, Path=OverlapVM_New.OverlapActivityCheckedCommand}" CommandParameter="{Binding ElementName=chkPlans}" Margin="3,0,0,0">
                                        </RadioButton>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>


                            <sdk:DataGridTextColumn Header="Unit Name" Width="*"  Binding="{Binding UnitName, Mode=OneWay}"  MinWidth="100"/>
                            <sdk:DataGridTextColumn Header="Activity" Width="*"  Binding="{Binding ActivityCode, Mode=TwoWay}"  MinWidth="90"/>
                            <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=dd/MM/yyyy}"  Width="120"/>
                            <sdk:DataGridTextColumn Header="End Date"   Binding="{Binding End,   Mode=OneWay, StringFormat=dd/MM/yyyy}"  Width="120"/>
                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>


                </Grid>

                <StackPanel Grid.Column="2" HorizontalAlignment="Left" Margin="20,0">
                    <Button Tag="simops" Name="btnApplySimops" Content="Apply OP - SIMOPS" Width="150"  Style="{StaticResource OverlapButtonStyle}"  
                                IsEnabled="{Binding IsApplySimopsButtonEnabled}" Margin="0,26,0,20" Command="{Binding Path=ApplySimopsCommand}" 
        							                    CommandParameter="{Binding ElementName=btnApplySimops}" Cursor="Hand" />
                    <Button Content="Cancel OP - SIMOPS" Width="150" x:Name="btnCancelSimops" Style="{StaticResource OverlapButtonStyle}" 
                    	IsEnabled="{Binding IsCancelSimopsButtonEnabled}" Margin="0,0,0,20" Command="{Binding CancelSimopsCommand}" 
                    	CommandParameter="{Binding ElementName=btnCancelSimops}" Cursor="Hand"/>

                    <Button Name="btnSelectedCheckOverlapGroup" Content="Update" Width="150"  Style="{StaticResource OverlapButtonStyle}" 
                                IsEnabled="{Binding IsCheckOverlapButtonEnabled}" Margin="0" Command="{Binding Path=OverlapCheckCommand}" 
        							                   CommandParameter="{Binding ElementName=btnSelectedCheckOverlapGroup}" Cursor="Hand" />
                </StackPanel>

                <Grid x:Name="planReschedulePanel" Grid.Column="3" Margin="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Modified Activities" Grid.Row="0" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,5"/>


                    <sdk:DataGrid x:Name="planRescheduledGrid" Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding ModifiedActivities}"
                           Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch">

                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTemplateColumn Header="">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <RadioButton Name="chkCancelPlans" Tag="{Binding DB_OverlapId}" Visibility="{Binding SIMOPSRadioButtonVisibility}" 
                                                   Command="{Binding Source={StaticResource ServiceLocator}, Path=OverlapVM_New.OverlapModifiedActivityCheckedCommand}" CommandParameter="{Binding ElementName=chkCancelPlans}">
                                        </RadioButton>
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>

                            <sdk:DataGridTextColumn Header="Unit Name" Width="*" Binding="{Binding UnitName, Mode=OneWay}"  MinWidth="85"/>
                            <sdk:DataGridTextColumn Header="Activity" Width="*"  Binding="{Binding ActivityCode, Mode=TwoWay}"  MinWidth="85"/>
                            <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=dd/MM/yyyy}" Width="120"/>
                            <sdk:DataGridTextColumn Header="End Date"   Binding="{Binding End, Mode=OneWay, StringFormat=dd/MM/yyyy}" Width="120" />
                            <sdk:DataGridTextColumn Header="Notes" Width="*" Binding="{Binding ModificationReason, Mode=TwoWay}" MinWidth="130"/>
                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>

                </Grid>
            </Grid>

            <Path Data="M25.666672,37 L204.34454,37" Margin="0,20,0,10" Grid.Row="1" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="False" VerticalAlignment="Top" Height="1" Stroke="{StaticResource LineColor}"/>

            <Grid Margin="0" Grid.Row="2" Height="Auto">
                <local:UCAppointment_New x:Name="overlapAppointment" />
            </Grid>

        </Grid>

    </Grid>
</UserControl>
